/* FoxGUI - The fast, flexible, free Amiga GUI system
Copyright (C) 2001 Simon Fox (Foxysoft)
This library is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense as published by the Free Software Foundation; eitherversion 2.1 of the License, or (at your option) any later version.This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/* Although for private Gui windows, the second parameter can be derived from the first (pgs->scr), if
the screen is public, the first parameter can be NULL because this function now gets all of the screen
info it needs (apart from a pointer to the parent GuiScreen structure to copy into the GuiWindow
structure) from the second parameter. */
GuiWindow *CreateGuiWindow(GuiScreen *pgs, struct Screen *Scr, int Left, int Top, int Width, int Height, int Dpen, int Bpen, char *Title, int flags, int (* __far __stdargs eventfn)(struct GWS*, int event, int x, int y, void*))
{
static long Number = 0L;
GuiWindow *c;
char name[5];
Diagnostic("CreateGuiWindow", ENTER, TRUE);
if (!Scr)
{
Diagnostic("CreateGuiWindow", EXIT, FALSE);
return NULL;
}
if ((flags & GW_CONSOLE) && !ICanOpenWindow(Scr))
{
Diagnostic("CreateGuiWindow", EXIT, FALSE);
return NULL;
}
sprintf(name, "%ld\0", ++Number);
if (!(c = (GuiWindow *) GuiMalloc(sizeof(GuiWindow), 0)))
{
Diagnostic("CreateGuiWindow", EXIT, FALSE);
return NULL;
}
if (!(c->WidgetData = (Widget *) GuiMalloc(sizeof(Widget), 0)))
{
GuiFree(c);
Diagnostic("CreateGuiWindow", EXIT, FALSE);
return NULL;
}
c->WidgetData->ObjectType = WindowObject;
c->EventFn = eventfn;
c->WidgetData->flags = flags;
c->WidgetData->NextWidget = NULL;
c->WidgetData->ChildWidget = NULL;
c->NewWin.FirstGadget = NULL;
c->NewWin.Screen = Scr;
c->NewWin.LeftEdge = Left;
c->NewWin.TopEdge = Top;
c->NewWin.Width = Width;
c->NewWin.Height = Height;
c->NewWin.DetailPen = Dpen;
c->NewWin.BlockPen = Bpen;
c->NewWin.Title = Title;
c->NewWin.MinWidth = Width;
c->NewWin.MinHeight = Height;
c->NewWin.MaxWidth = (unsigned short) ~0; // Allows a window as wide as the screen
c->NewWin.MaxHeight = (unsigned short) ~0; // Allows a window as high as the screen
/* Open the window using the 3D look but in a backwards compatible way
rather than using OpenWindowTags() or OpenWindowTagList() which are
simpler but not backwards compatible */
if (!(c->Win = (struct Window *) OpenWindow((struct NewWindow *) &(c->NewWin))))
{
GuiFree(c->WidgetData);
GuiFree(c);
Diagnostic("CreateGuiWindow", EXIT, FALSE);
return NULL;
}
if (flags & GW_CONSOLE)
{
if (!(c->Con = (struct Console *) GuiMalloc(sizeof(struct Console), 0)))
{
CloseWindow(c->Win);
GuiFree(c->WidgetData);
GuiFree(c);
Diagnostic("CreateGuiWindow", EXIT, FALSE);
return NULL;
}
if (!OpenConsole(c->Con, c->Win, name))
{
GuiFree(c->Con);
CloseWindow(c->Win);
GuiFree(c->WidgetData);
GuiFree(c);
Diagnostic("CreateGuiWindow", EXIT, FALSE);
return NULL;
}
}
AbortAllMessages();
c->WidgetData->Parent = pgs;
c->ParentScreen = Scr;
c->Enabled = c->OldStatus = TRUE;
c->Sleep = FALSE;
c->FirstMenu = NULL;
c->MenuFn = NULL;
if (flags & GW_CONSOLE)
c->ConReadSig = 1L << c->Con->RePort->mp_SigBit;
else
c->ConReadSig = 0;
c->WindowSig = 1L << c->Win->UserPort->mp_SigBit;
c->previous = NULL;
c->next = Gui.GWLfirst;
if (Gui.GWLfirst)
Gui.GWLfirst->previous = c;
Gui.GWLfirst = c;
QueueAllMessages();
Diagnostic("CreateGuiWindow", EXIT, TRUE);
return c;
}
BOOL FOXLIB SetWindowLimits(REGA0 GuiWindow *gw, REGD0 long minwidth, REGD1 long minheight, REGD2 unsigned long maxwidth, REGD3 unsigned long maxheight)